'use strict';
const db = uniCloud.database();
const dbCmd = db.command;
const $ = dbCmd.aggregate;
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	
	//返回数据给客户端
	return await db.collection('comment')
	.aggregate()
	.match(
		{
			memoryId: event.memoryId,
		}
	)
	.lookup({
		from:'uni-id-users',
		localField:'user_id',
		foreignField:'_id',
		as:'user_id'
	})
	.sort(
		{	
		createTime:1
		}
	).end()
	
};
